﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SQLite;

namespace festivalDatabase
{
    public partial class viewReports : userInterface
    {
        private int grandTotal;
        bool tableIsUp;

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="db"></param>
        /// <param name="festID"></param>
        public viewReports(dbAccessor db, int festID)
        {
            tableIsUp = false;
            InitializeComponent();
            dbAccess = db;
            setIcon();
            currentFestivalID = festID;
            updateFestivalList();
            setInitialSelections();
            setupTable();
        }

        /// <summary>
        /// Creates rows and columns in the datatable and sets bool to indicate the table is up.
        /// </summary>
        private void setupTable()
        {
            reportsDataGrid.RowHeadersVisible = false;
            reportsDataGrid.ColumnHeadersVisible = false;
            reportsDataGrid.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
            
            for (int i = 0; i < 28; i++)
                reportsDataGrid.Columns.Add("", "");

            for (int i = 0; i < 26; i++)
                reportsDataGrid.Rows.Add();

            tableIsUp = true;
        }

        /// <summary>
        /// Clears the datatable.
        /// </summary>
        private void clearTable()
        {
            for (int i = 0; i < 28; i++)
                for (int j = 0; j < 26; j++)
                    reportsDataGrid.Rows[j].Cells[i].Value = "";
        }

        /// <summary>
        /// Populates the festivals combo box.
        /// </summary>
        private void updateFestivalList()
        {
            SQLiteCommand query = dbAccess.getCommand();
            query.CommandText = "SELECT name, id " +
                                "FROM festival;";
            DataTable dt = dbAccess.executeQuery(query);

            foreach (DataRow row in dt.Rows)
            {
                festivalComboBox.Items.Add(row["name"].ToString() + ", " + row["id"].ToString());
            }
        }

        /// <summary>
        /// Populates the menus when a new festival is selected.
        /// </summary>
        private void setInitialSelections()
        {
            financialReportRadioButton.Checked = true;

            SQLiteCommand query = dbAccess.getCommand();
            query.CommandText = "SELECT start_date, end_date, festival_type " +
                                "FROM festival " +
                                "WHERE id = @ID;";
            SQLiteParameter param = new SQLiteParameter("@ID", currentFestivalID);
            query.Parameters.Add(param);

            DataTable dt = dbAccess.executeQuery(query);

            setDates(dt.Rows[0]["start_date"].ToString(), dt.Rows[0]["end_date"].ToString());

            if (dt.Rows[0]["festival_type"].ToString() == "Music")
            {
                currentFestivalType = festivalTypes.Music;
                musicScheduleRadioButton.Visible = true;
            }
            else
            {
                currentFestivalType = festivalTypes.Art;
                musicScheduleRadioButton.Visible = false;
            }

            string currentFestID = currentFestivalID.ToString();

            for (int i = 0; i < festivalComboBox.Items.Count; i++)
            {
                string selectedFestID = getFestivalNumber(festivalComboBox.Items[i].ToString());
                if (currentFestID == selectedFestID)
                {
                    festivalComboBox.SelectedIndex = i;
                    break;
                }
            }
        }

        /// <summary>
        /// Sets the date labels for the currently selected festival.
        /// </summary>
        /// <param name="start_date"></param>
        /// <param name="end_date"></param>
        private void setDates(string start_date, string end_date)
        {
            string date_string = formatDateStringForDisplay(start_date);
            if (date_string.Length != 0)
            {
                date_string = date_string.Insert(2, "/");
                date_string = date_string.Insert(5, "/");
            }
            startDateLabel.Text = "Start: " + date_string;
            dateMaskedTextBox.Text = date_string;

            date_string = formatDateStringForDisplay(end_date);
            if (date_string.Length != 0)
            {
                date_string = date_string.Insert(2, "/");
                date_string = date_string.Insert(5, "/");
            }
            endDateLabel.Text = "Start: " + date_string;
        }

        /// <summary>
        /// Validates input and determines which report to run. Calls the method to run that report.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void runReportButton_Click(object sender, EventArgs e)
        {
            errorProvider.Clear();
            clearTable();
            if (validNumLength(dateMaskedTextBox.Text, 8, false))
            {
                if (financialReportRadioButton.Checked)
                {
                    runFinancialReport();
                }
                else if (vendorReportRadioButton.Checked)
                {
                    runVendorReport();
                }
                else if (sponsorReportRadioButton.Checked)
                {
                    runSponsorReport();
                }
                else
                {
                    if (stageIsInComboBox())
                        runMusicScheduleReport();
                    else
                        MessageBox.Show("Please select a valid stage");
                }
            }
            else
            {
                errorProvider.SetError(dateMaskedTextBox, "Please indicate a valid date.");
            }
        }

        /// <summary>
        /// Returns only the year portion of the date in the date text box.
        /// </summary>
        /// <returns></returns>
        private string getYear()
        {
            return getFestivalNumber(dateMaskedTextBox.Text);
        }

        /// <summary>
        /// Prints all festivals' financial summaries.
        /// </summary>
        private void runFinancialReport()
        {
            if (validNumLength(dateMaskedTextBox.Text, 8, false))
            {
                festivalComboBox.Text = "";
                tableTitleLabel.Text = getYear() + " Festival Financial Report";
                int rowNum = 1;
                int colNum = 4;

                reportsDataGrid.Rows[rowNum].Cells[colNum].Value = "Sponsorship";
                colNum += 2;
                reportsDataGrid.Rows[rowNum++].Cells[colNum].Value = "Performance";
                colNum -= 5;
                reportsDataGrid.Rows[rowNum].Cells[colNum++].Value = "Festival ID";
                reportsDataGrid.Rows[rowNum].Cells[colNum++].Value = "Festival Name";
                reportsDataGrid.Rows[rowNum].Cells[colNum++].Value = "Year";
                reportsDataGrid.Rows[rowNum].Cells[colNum++].Value = "Income";
                reportsDataGrid.Rows[rowNum].Cells[colNum++].Value = "Vendor Income";
                reportsDataGrid.Rows[rowNum].Cells[colNum++].Value = "Fees Paid";
                reportsDataGrid.Rows[rowNum].Cells[colNum].Value = "Revenue";

                rowNum += 2;
                colNum -= 6;

                SQLiteCommand query = dbAccess.getCommand();
                query.CommandText = "SELECT id, name " +
                                    "FROM festival " +
                                    "WHERE start_date>=@start AND start_date<=@end " +
                                    "ORDER BY id;";
                SQLiteParameter param = new SQLiteParameter("@start", startOfYear());
                query.Parameters.Add(param);
                param = new SQLiteParameter("@end", endOfYear());
                query.Parameters.Add(param);

                DataTable dt = dbAccess.executeQuery(query);

                grandTotal = 0;

                try
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        rowNum = printFestivalProfitLoss(Int32.Parse(row["id"].ToString()), row["name"].ToString(), rowNum, colNum);
                    }
                }
                catch
                {
                    // do nothing
                }

                reportsDataGrid.Rows[rowNum].Cells[++colNum].Value = "Total Revenue";
                colNum += 5;
                reportsDataGrid.Rows[rowNum].Cells[colNum].Value = grandTotal;
            }
        }

        /// <summary>
        /// Prints information about a specific festival as a helper method to runFinancialReport().
        /// </summary>
        /// <param name="festNum"></param>
        /// <param name="festName"></param>
        /// <param name="rowNum"></param>
        /// <param name="colNum"></param>
        /// <returns></returns>
        private int printFestivalProfitLoss(int festNum, string festName, int rowNum, int colNum)
        {
            SQLiteCommand query = dbAccess.getCommand();
            query.CommandText = "SELECT SUM(donation_amt) AS sponsorshipIncome " +
                                "FROM festival_has_sponsor " +
                                "WHERE festival_id=@festID;";
            SQLiteParameter param = new SQLiteParameter("@festID", festNum);
            query.Parameters.Add(param);
            DataTable dt = dbAccess.executeQuery(query);

            reportsDataGrid.Rows[rowNum].Cells[colNum++].Value = festNum;
            reportsDataGrid.Rows[rowNum].Cells[colNum++].Value = festName;
            reportsDataGrid.Rows[rowNum].Cells[colNum++].Value = getYear();
            int sponsorInc;
            try
            {
                sponsorInc = Int32.Parse(dt.Rows[0]["sponsorshipIncome"].ToString());
                reportsDataGrid.Rows[rowNum].Cells[colNum++].Value = sponsorInc;
            }
            catch
            {
                sponsorInc = 0;
                reportsDataGrid.Rows[rowNum].Cells[colNum++].Value = sponsorInc;
            }

            query = dbAccess.getCommand();
            query.CommandText = "SELECT SUM(fee) AS vendorIncome " +
                                "FROM festival_has_vendor " +
                                "JOIN vendor ON festival_has_vendor.vendor_license_num=vendor.license_number " +
                                "JOIN category ON category.id=vendor.category " +
                                "WHERE festival_id=@festID;";
            query.Parameters.Add(param);
            dt = dbAccess.executeQuery(query);

            int vendInc;
            try
            {
                vendInc = Int32.Parse(dt.Rows[0]["vendorIncome"].ToString());
                reportsDataGrid.Rows[rowNum].Cells[colNum++].Value = vendInc;
            }
            catch
            {
                vendInc = 0;
                reportsDataGrid.Rows[rowNum].Cells[colNum++].Value = vendInc;
            }

            query = dbAccess.getCommand();
            query.CommandText = "SELECT SUM(performance_fee) AS feesPaid " +
                                "FROM musician_plays JOIN musician ON musician.musician_name=musician_plays.musician_name " +
                                "WHERE festival_id=@festID;";
            query.Parameters.Add(param);
            dt = dbAccess.executeQuery(query);

            int cost;
            try
            {
                cost = Int32.Parse(dt.Rows[0]["feesPaid"].ToString());
                reportsDataGrid.Rows[rowNum].Cells[colNum++].Value = cost;
            }
            catch
            {
                cost = 0;
                reportsDataGrid.Rows[rowNum].Cells[colNum++].Value = cost;
            }

            int festRevenue = sponsorInc + vendInc - cost;
            reportsDataGrid.Rows[rowNum].Cells[colNum].Value = festRevenue;
            rowNum += 2;

            grandTotal += festRevenue;

            return rowNum;
        }

        /// <summary>
        /// Displays a summary report about all vendors for the year indicated in the date text box.
        /// </summary>
        private void runVendorReport()
        {
            if (validNumLength(dateMaskedTextBox.Text, 8, false))
            {
                festivalComboBox.Text = "";
                tableTitleLabel.Text = "  " + getYear() + " Festival Vendor Report";

                int rowNum = 0, colNum = 1;

                reportsDataGrid.Rows[rowNum].Cells[colNum++].Value = "Festival";
                reportsDataGrid.Rows[rowNum].Cells[colNum++].Value = "Festival";
                reportsDataGrid.Rows[rowNum].Cells[colNum++].Value = "Start";
                reportsDataGrid.Rows[rowNum].Cells[colNum++].Value = "End";
                reportsDataGrid.Rows[rowNum].Cells[colNum++].Value = "Vendor";
                colNum++;
                reportsDataGrid.Rows[rowNum++].Cells[colNum].Value = "Total";
                colNum = 1;
                reportsDataGrid.Rows[rowNum].Cells[colNum++].Value = "ID";
                reportsDataGrid.Rows[rowNum].Cells[colNum++].Value = "Name";
                reportsDataGrid.Rows[rowNum].Cells[colNum++].Value = "Date";
                reportsDataGrid.Rows[rowNum].Cells[colNum++].Value = "Date";
                reportsDataGrid.Rows[rowNum].Cells[colNum++].Value = "Category";
                reportsDataGrid.Rows[rowNum].Cells[colNum++].Value = "Count";
                reportsDataGrid.Rows[rowNum++].Cells[colNum].Value = "Fees";
                rowNum++;
                colNum = 1;

                SQLiteCommand query = dbAccess.getCommand();
                query.CommandText = "SELECT id, name, start_date, end_date " +
                                    "FROM festival;";
                DataTable dt = dbAccess.executeQuery(query);

                grandTotal = 0;
                foreach (DataRow row in dt.Rows)
                {
                    rowNum = showVendorCategories(row, rowNum, colNum);
                    rowNum++;
                }

                reportsDataGrid.Rows[rowNum].Cells[colNum].Value = "Grand Total";
                colNum += 6;
                reportsDataGrid.Rows[rowNum].Cells[colNum].Value = grandTotal;
            }
        }

        /// <summary>
        /// Prints the vendor categories in decreasing order of fee along with
        /// the number of vendors of each type and the total funds raised by type.
        /// Also prints the subtotal for the current festival.
        /// </summary>
        /// <param name="row">a row containing the current festival ID, name, start_date, and end_date</param>
        /// <param name="rowNum">index into the datagrid to begin printing</param>
        /// <param name="colNum">index into the datagrid to begin printing</param>
        /// <returns>allows the calling method to resume printing on the next row of the DataGrid</returns>
        private int showVendorCategories(DataRow row, int rowNum, int colNum)
        {
            reportsDataGrid.Rows[rowNum].Cells[colNum++].Value = row["id"].ToString();
            reportsDataGrid.Rows[rowNum].Cells[colNum++].Value = row["name"].ToString();
            string date = formatDateStringForDisplay(row["start_date"].ToString());
            if (date.Length > 0)
            {
                date = date.Insert(2, "/");
                date = date.Insert(5, "/");
            }
            reportsDataGrid.Rows[rowNum].Cells[colNum++].Value = date;
            date = formatDateStringForDisplay(row["end_date"].ToString());
            if (date.Length > 0)
            {
                date = date.Insert(2, "/");
                date = date.Insert(5, "/");
            }
            reportsDataGrid.Rows[rowNum].Cells[colNum++].Value = date;
            SQLiteCommand query = dbAccess.getCommand();
            query.CommandText = "SELECT description, COUNT(*) AS count, SUM(fee) AS sum " +
                                "FROM (festival_has_vendor JOIN vendor ON festival_has_vendor.vendor_license_num = vendor.license_number) " +
                                "JOIN category ON category.id = vendor.category " +
                                "WHERE festival_id = @festID " +
                                "GROUP BY description ORDER BY fee DESC;";
            SQLiteParameter param = new SQLiteParameter("@festID", Int32.Parse(row["id"].ToString()));
            query.Parameters.Add(param);
            DataTable vendorTable = dbAccess.executeQuery(query);
            int startVendorInfoCol = colNum;
            foreach (DataRow r in vendorTable.Rows)
            {
                reportsDataGrid.Rows[rowNum].Cells[colNum++].Value = r["description"].ToString();
                reportsDataGrid.Rows[rowNum].Cells[colNum++].Value = r["count"].ToString();
                reportsDataGrid.Rows[rowNum].Cells[colNum++].Value = r["sum"].ToString();
                rowNum++;
                colNum = startVendorInfoCol;
            }
            rowNum++;
            colNum = 1;
            reportsDataGrid.Rows[rowNum].Cells[colNum].Value = "Sub Total";
            query = dbAccess.getCommand();
            query.CommandText = "SELECT SUM(fee) AS subtotal FROM (festival_has_vendor JOIN vendor ON festival_has_vendor.vendor_license_num = vendor.license_number) " +
                                "JOIN category ON category.id = vendor.category " +
                                "WHERE festival_id = @festID;";
            param = new SQLiteParameter("@festID", Int32.Parse(row["id"].ToString()));
            query.Parameters.Add(param);
            DataTable subTotal = dbAccess.executeQuery(query);
            colNum += 6;
            reportsDataGrid.Rows[rowNum++].Cells[colNum].Value = subTotal.Rows[0]["subtotal"];
            if (subTotal.Rows[0]["subtotal"].ToString() != "")
                grandTotal += Int32.Parse(subTotal.Rows[0]["subtotal"].ToString());
            return rowNum;
        }

        /// <summary>
        /// Displays the sponsors and their donations for a given year.
        /// Year the report is run is determined by the year of the currently active festival.
        /// </summary>
        private void runSponsorReport()
        {
            tableTitleLabel.Text = "     " + getYear() + " Sponsors Report";
            int rowNum = 1;
            int colNum = 9;

            reportsDataGrid.Rows[rowNum].Cells[colNum++].Value = "Sponsor";
            reportsDataGrid.Rows[rowNum].Cells[colNum--].Value = "Donations";
            rowNum += 2;

            SQLiteCommand query = dbAccess.getCommand();
            query.CommandText = "SELECT sponsor_org, SUM(donation_amt) AS amt " +
                                "FROM festival JOIN festival_has_sponsor " +
                                "ON festival.id=festival_has_sponsor.festival_id " +
                                "WHERE start_date>=@start AND start_date<=@end " +
                                "GROUP BY sponsor_org " +
                                "ORDER BY amt DESC;";
            string date = startOfYear();
            SQLiteParameter param = new SQLiteParameter("@start", date);
            query.Parameters.Add(param);
            date = endOfYear();
            param = new SQLiteParameter("@end", date);
            query.Parameters.Add(param);

            DataTable dt = dbAccess.executeQuery(query);

            foreach (DataRow row in dt.Rows)
            {
                reportsDataGrid.Rows[rowNum].Cells[colNum++].Value = row["sponsor_org"];
                reportsDataGrid.Rows[rowNum++].Cells[colNum--].Value = row["amt"];
            }

            query = dbAccess.getCommand();
            query.CommandText = "SELECT SUM(donation_amt) as total " +
                                "FROM festival JOIN festival_has_sponsor " +
                                        "ON festival.id=festival_has_sponsor.festival_id JOIN sponsor " +
                                        "ON festival_has_sponsor.sponsor_org=sponsor.organization " +
                                "WHERE start_date>=@start AND start_date<=@end;";
            date = startOfYear();
            param = new SQLiteParameter("@start", date);
            query.Parameters.Add(param);
            date = endOfYear();
            param = new SQLiteParameter("@end", date);
            query.Parameters.Add(param);

            try
            {
                dt = dbAccess.executeQuery(query);
                reportsDataGrid.Rows[++rowNum].Cells[colNum++].Value = "Total Donations";
                reportsDataGrid.Rows[rowNum].Cells[colNum].Value = dt.Rows[0]["total"];
            }
            catch
            {
                reportsDataGrid.Rows[rowNum].Cells[colNum].Value = 0;
            }
        }

        /// <summary>
        /// Displays the schedule for the selected stage on the indicated
        /// date at the selected music festival.
        /// </summary>
        private void runMusicScheduleReport()
        {
            if (stageIsInComboBox())
            {
                tableTitleLabel.Text = "         Music Schedule";

                int rowNum = 1;
                int colNum = 5;

                reportsDataGrid.Rows[rowNum].Cells[colNum++].Value = "Festival ID";
                reportsDataGrid.Rows[rowNum].Cells[colNum++].Value = "Festival Name";
                reportsDataGrid.Rows[rowNum].Cells[colNum++].Value = "Stage";
                reportsDataGrid.Rows[rowNum].Cells[colNum].Value = "Date";
                rowNum += 2;
                colNum = colNum - 3;

                SQLiteCommand query = dbAccess.getCommand();
                query.CommandText = "SELECT name " +
                                    "FROM festival " +
                                    "WHERE id = @festID;";
                SQLiteParameter param = new SQLiteParameter("@festID", currentFestivalID);
                query.Parameters.Add(param);
                DataTable festName = dbAccess.executeQuery(query);

                reportsDataGrid.Rows[rowNum].Cells[colNum++].Value = currentFestivalID;
                reportsDataGrid.Rows[rowNum].Cells[colNum++].Value = festName.Rows[0]["name"].ToString();
                reportsDataGrid.Rows[rowNum].Cells[colNum++].Value = stageNameComboBox.Text.ToString();
                reportsDataGrid.Rows[rowNum].Cells[colNum].Value = dateMaskedTextBox.Text;
                rowNum += 2;
                colNum -= 2;
                reportsDataGrid.Rows[rowNum].Cells[colNum++].Value = "Time";
                reportsDataGrid.Rows[rowNum++].Cells[colNum--].Value = "Artist";

                query = dbAccess.getCommand();
                query.CommandText = "SELECT time, musician_name " +
                                    "FROM musician_plays " +
                                    "WHERE date=@date AND stage_name=@stage;";

                string date = formatGenericDate(dateMaskedTextBox.Text);
                param = new SQLiteParameter("@date", date);
                query.Parameters.Add(param);
                param = new SQLiteParameter("@stage", stageNameComboBox.Text);
                query.Parameters.Add(param);

                DataTable dt = dbAccess.executeQuery(query);

                foreach (DataRow row in dt.Rows)
                {
                    reportsDataGrid.Rows[rowNum].Cells[colNum++].Value = row["time"];
                    reportsDataGrid.Rows[rowNum++].Cells[colNum--].Value = row["musician_name"];
                }
            }
        }

        /// <summary>
        /// Determines if the stage selection is actually in the combo box or if
        /// it was typed in manually and does not exist.
        /// </summary>
        /// <returns></returns>
        private bool stageIsInComboBox()
        {
            if (stageNameComboBox.Text == "(No stages)")
                return false;

            SQLiteCommand query = dbAccess.getCommand();
            query.CommandText = "SELECT stage_name " +
                                            "FROM music_festival_has_stage " +
                                            "WHERE festival_id=@festID;";
            SQLiteParameter param = new SQLiteParameter("@festID", currentFestivalID);
            query.Parameters.Add(param);
            DataTable stageNames = dbAccess.executeQuery(query);

            foreach (DataRow stage in stageNames.Rows)
            {
                if (stage["stage_name"].ToString() == stageNameComboBox.Text)
                    return true;
            }

            return false;
        }

        /// <summary>
        /// Handles the switching of the GUI to reflect the newly selected festival.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void festivalComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            currentFestivalID = Int32.Parse(getFestivalNumber(festivalComboBox.Text));
            SQLiteCommand query = dbAccess.getCommand();
            query.CommandText = "SELECT festival_type, start_date, end_date " +
                                "FROM festival " +
                                "WHERE id = @ID;";
            SQLiteParameter param = new SQLiteParameter("@ID", currentFestivalID);
            query.Parameters.Add(param);
            DataTable dt = dbAccess.executeQuery(query);
            setDates(dt.Rows[0]["start_date"].ToString(), dt.Rows[0]["end_date"].ToString());
            if (dt.Rows[0]["festival_type"].ToString() == "Music")
            {
                currentFestivalType = festivalTypes.Music;
                musicScheduleRadioButton.Visible = true;
                setStagesComboBox();
            }
            else
            {
                currentFestivalType = festivalTypes.Art;
                musicScheduleRadioButton.Visible = false;
            }

            financialReportRadioButton.Checked = true;
            if (tableIsUp)
                clearTable();
        }

        /// <summary>
        /// Populates the stages combo box for the currently selected music festival.
        /// </summary>
        private void setStagesComboBox()
        {
            stageNameComboBox.Items.Clear();
            SQLiteCommand query = dbAccess.getCommand();
            query.CommandText = "SELECT stage_name " +
                                "FROM music_festival_has_stage " +
                                "WHERE festival_id=@festID;";
            SQLiteParameter param = new SQLiteParameter("@festID", currentFestivalID);
            query.Parameters.Add(param);
            DataTable stageNames = dbAccess.executeQuery(query);
            
            foreach (DataRow stage in stageNames.Rows)
                stageNameComboBox.Items.Add(stage["stage_name"].ToString());

            if (stageNameComboBox.Items.Count == 0)
                stageNameComboBox.Items.Add("(No stages)");
        }

        /// <summary>
        /// Displays or hides the stage name combo box and label.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void musicScheduleRadioButton_CheckedChanged(object sender, EventArgs e)
        {
            if (musicScheduleRadioButton.Checked)
            {
                stageNameComboBox.Visible = true;
                stageNameLabel.Visible = true;
            }
            else
            {
                stageNameComboBox.Visible = false;
                stageNameLabel.Visible = false;
            }
        }

        /// <summary>
        /// Returns the first day of the year of the date in the date text box.
        /// </summary>
        /// <returns></returns>
        private string startOfYear()
        {
            string result = getYear() + "-01-01";
            return result;
        }

        /// <summary>
        /// Returns the last day of the year of the date in the date text box.
        /// </summary>
        /// <returns></returns>
        private string endOfYear()
        {
            string result = getYear() +"-12-31";
            return result;
        }
    }
}
